﻿using System;
using System.Collections.Generic;
using System.Text;

namespace AdaptiveAgents.Tools
{
    class AgentComperator
    {

        public static AgentInfo getBiggest(AgentInfo agent0, AgentInfo agent1, AgentInfo agent2)
        {
            if ((agent0.getCompetence() < agent2.getCompetence()) && (agent1.getCompetence() < agent2.getCompetence()))
                return agent2;
            if ((agent0.getCompetence() < agent1.getCompetence()) && (agent2.getCompetence() < agent1.getCompetence()))
                return agent1;
            if ((agent1.getCompetence() < agent0.getCompetence()) && (agent2.getCompetence() < agent0.getCompetence()))
                return agent0;
            return null;
        }
        
        public static AgentInfo getSmallest(AgentInfo agent0, AgentInfo agent1, AgentInfo agent2)
        {
            if ((agent0.getCompetence() < agent2.getCompetence()) && (agent0.getCompetence() < agent1.getCompetence()))
                return agent0;
            if ((agent1.getCompetence() < agent0.getCompetence()) && (agent1.getCompetence() < agent2.getCompetence()))
                return agent1;
            if ((agent2.getCompetence() < agent0.getCompetence()) && (agent2.getCompetence() < agent1.getCompetence()))
                return agent2;
            return null;
        }

        public static AgentInfo getMidlle(AgentInfo agent0, AgentInfo agent1, AgentInfo agent2)
        {
            if ((agent1.getCompetence() < agent0.getCompetence()) && (agent0.getCompetence() < agent2.getCompetence()))
                return agent0;
            if ((agent2.getCompetence() < agent0.getCompetence()) && (agent0.getCompetence() < agent1.getCompetence()))
                return agent0;
            if ((agent0.getCompetence() < agent1.getCompetence()) && (agent1.getCompetence() < agent2.getCompetence()))
                return agent1;
            if ((agent2.getCompetence() < agent1.getCompetence()) && (agent1.getCompetence() < agent0.getCompetence()))
                return agent1;
            if ((agent0.getCompetence() < agent2.getCompetence()) && (agent2.getCompetence() < agent1.getCompetence()))
                return agent2;
            if ((agent1.getCompetence() < agent2.getCompetence()) && (agent2.getCompetence() < agent0.getCompetence()))
                return agent2;
            return null;
        }

        public static int getAgentLevel(AgentInfo agent0, AgentInfo agent1, AgentInfo agent2)
        {
            double ag0 = agent0.getCompetence();
            double ag1 = agent1.getCompetence();
            double ag2 = agent2.getCompetence();

            return DoubleComperator.getPosition(ag0, ag1, ag2);
        }
    
    
    }
}
